package com.fluxtah.jordl.examples.twitter;

import com.fluxtah.jordl.lib.Transformer;
import com.fluxtah.jordl.lib.TransformException;
import org.json.JSONObject;
import org.json.JSONException;

public class TwitterUserInputTransformer extends Transformer<JSONObject, TwitterUser> {
	public void transform(JSONObject source, TwitterUser target) throws TransformException {
		try {
			if(source.has("contributors_enabled") && !source.isNull("contributors_enabled")) {
				target.setContributorsEnabled(source.getBoolean("contributors_enabled"));
			}
			if(source.has("created_at") && !source.isNull("created_at")) {
				target.setCreatedAt(source.getString("created_at"));
			}
			if(source.has("default_profile") && !source.isNull("default_profile")) {
				target.setDefaultProfile(source.getBoolean("default_profile"));
			}
			if(source.has("default_profile_image") && !source.isNull("default_profile_image")) {
				target.setDefaultProfileImage(source.getBoolean("default_profile_image"));
			}
			if(source.has("description") && !source.isNull("description")) {
				target.setDescription(source.getString("description"));
			}
			if(source.has("favourites_count") && !source.isNull("favourites_count")) {
				target.setFavouritesCount(source.getInt("favourites_count"));
			}
			if(source.has("followers_count") && !source.isNull("followers_count")) {
				target.setFollowersCount(source.getInt("followers_count"));
			}
			if(source.has("friends_count") && !source.isNull("friends_count")) {
				target.setFriendsCount(source.getInt("friends_count"));
			}
			if(source.has("geo_enabled") && !source.isNull("geo_enabled")) {
				target.setGeoEnabled(source.getBoolean("geo_enabled"));
			}
			if(source.has("id") && !source.isNull("id")) {
				target.setId(source.getLong("id"));
			}
			if(source.has("id_str") && !source.isNull("id_str")) {
				target.setIdStr(source.getString("id_str"));
			}
			if(source.has("is_translator") && !source.isNull("is_translator")) {
				target.setIsTranslator(source.getBoolean("is_translator"));
			}
			if(source.has("lang") && !source.isNull("lang")) {
				target.setLang(source.getString("lang"));
			}
			if(source.has("listed_count") && !source.isNull("listed_count")) {
				target.setListedCount(source.getInt("listed_count"));
			}
			if(source.has("location") && !source.isNull("location")) {
				target.setLocation(source.getString("location"));
			}
			if(source.has("name") && !source.isNull("name")) {
				target.setName(source.getString("name"));
			}
			if(source.has("profile_background_color") && !source.isNull("profile_background_color")) {
				target.setProfileBackgroundColor(source.getInt("profile_background_color"));
			}
			if(source.has("profile_background_image_url") && !source.isNull("profile_background_image_url")) {
				target.setProfileBackgroundImageUrl(source.getString("profile_background_image_url"));
			}
			if(source.has("profile_background_image_url_https") && !source.isNull("profile_background_image_url_https")) {
				target.setProfileBackgroundImageUrlHttps(source.getString("profile_background_image_url_https"));
			}
			if(source.has("profile_background_tile") && !source.isNull("profile_background_tile")) {
				target.setProfileBackgroundTile(source.getBoolean("profile_background_tile"));
			}
			if(source.has("profile_image_url") && !source.isNull("profile_image_url")) {
				target.setProfileImageUrl(source.getString("profile_image_url"));
			}
			if(source.has("profile_image_url_https") && !source.isNull("profile_image_url_https")) {
				target.setProfileImageUrlHttps(source.getString("profile_image_url_https"));
			}
			if(source.has("profile_link_color") && !source.isNull("profile_link_color")) {
				target.setProfileLinkColor(source.getInt("profile_link_color"));
			}
			if(source.has("profile_sidebar_border_color") && !source.isNull("profile_sidebar_border_color")) {
				target.setProfileSidebarBorderColor(source.getInt("profile_sidebar_border_color"));
			}
			if(source.has("profile_sidebar_fill_color") && !source.isNull("profile_sidebar_fill_color")) {
				target.setProfileSidebarFillColor(source.getInt("profile_sidebar_fill_color"));
			}
			if(source.has("protected") && !source.isNull("protected")) {
				target.setProtected(source.getBoolean("protected"));
			}
			if(source.has("screen_name") && !source.isNull("screen_name")) {
				target.setScreenName(source.getString("screen_name"));
			}
			if(source.has("show_all_inline_media") && !source.isNull("show_all_inline_media")) {
				target.setShowAllInlineMedia(source.getBoolean("show_all_inline_media"));
			}
			if(source.has("statuses_count") && !source.isNull("statuses_count")) {
				target.setStatusesCount(source.getInt("statuses_count"));
			}
			if(source.has("url") && !source.isNull("url")) {
				target.setUrl(source.getString("url"));
			}
			if(source.has("verified") && !source.isNull("verified")) {
				target.setVerified(source.getBoolean("verified"));
			}
		} catch (JSONException x) {
			throw new TransformException(x);
		}
	}
}
